//
//  BaseTableViewController.swift
//  Weibo
//
//  Created by mac on 16/1/10.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit
import SnapKit

class BaseTableViewController: UITableViewController {

    var loginFlag: Bool = UserCountViewModel().userLoginFlag
    var vistorView: MainVistorView?
    override func loadView() {
        
        if loginFlag {
            super.loadView()
        }
        else {
            vistorView = MainVistorView()
            view = vistorView
            vistorView?.delegate = self
            setupNavBar()
        }
        
        
    }
    
    private func setupNavBar() {
        
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(title: "登录", style: .Plain, target: self, action: "userWillLogin")
        
        self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: "注册", style: .Plain, target: self, action: "userWillRegister")
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    override class func initialize() {
        UINavigationBar.appearance().tintColor = UIColor.orangeColor()
        
        UITabBar.appearance().tintColor = UIColor.orangeColor()
    }
    
}



extension BaseTableViewController:MainVistorViewDelegate {
    //MARK: 代理方法 用户点击登录按钮
    func userWillLogin() {
        let OauthLogin = OauthLoginViewController()
        
        let nav: UINavigationController = UINavigationController(rootViewController: OauthLogin)
        
        presentViewController(nav, animated: true, completion: nil)
    }
    
    //MARK: 代理方法  用户点击注册按钮
    func userWillRegister() {
        print("++++++")
    }
}



















